package com.lvan.producer.receive;

import com.lvan.producer.channel.MyProcessor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.stereotype.Component;

/**
 * @author luom
 * @date 2021/9/3
 */
@Component
@EnableBinding(MyProcessor.class)
public class SmsAndEmailMessageConsumer {

    private final Logger logger = LoggerFactory.getLogger(SmsAndEmailMessageConsumer.class);

    @StreamListener(MyProcessor.SMS_MESSAGE)
    public void receiveSms(String phoneNum) {
        logger.info("电话号码为:{},调用短信发送服务，发送短信......", phoneNum);
    }

    @StreamListener(MyProcessor.EMAIL_MESSAGE)
    public void receveEmail(String email) {
        logger.info("邮箱地址为:{},调用邮件发送服务，发送邮件......", email);
    }
}
